package com.xbts.web.controller.system;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
import javax.servlet.http.HttpServletResponse;

import com.xbts.common.utils.sign.Base64;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xbts.common.annotation.Log;
import com.xbts.common.core.controller.BaseController;
import com.xbts.common.core.domain.AjaxResult;
import com.xbts.common.enums.BusinessType;
import com.xbts.system.domain.CnNavigationBarContent;
import com.xbts.system.service.ICnNavigationBarContentService;
import com.xbts.common.utils.poi.ExcelUtil;
import com.xbts.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

/**
 * 导航条内容Controller
 * @author xbts
 * @date 2023-12-01
 */
@Api("导航条内容")
@RestController
@RequestMapping("/system/navigation/content")
public class CnNavigationBarContentController extends BaseController {

    @Autowired
    private ICnNavigationBarContentService cnNavigationBarContentService;

    /**
     * 查询导航条内容列表
     */
    @ApiOperation("查询导航条内容列表")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody CnNavigationBarContent cnNavigationBarContent) {
        startPage(cnNavigationBarContent);
        List<CnNavigationBarContent> list = cnNavigationBarContentService.selectCnNavigationBarContentList(cnNavigationBarContent);
        return getDataTable(list);
    }

    /**
     * 导出导航条内容列表
     */
    @ApiOperation("导出导航条内容列表")
    @PreAuthorize("@ss.hasPermi('system:navigationContent:export')")
    @Log(title = "导航条内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response,@RequestBody CnNavigationBarContent cnNavigationBarContent) {
        List<CnNavigationBarContent> list = cnNavigationBarContentService.selectCnNavigationBarContentList(cnNavigationBarContent);
        ExcelUtil<CnNavigationBarContent> util = new ExcelUtil<CnNavigationBarContent>(CnNavigationBarContent.class);
        util.exportExcel(response, list, "导航条内容数据");
    }

    /**
     * 获取导航条内容详细信息
     */
    @ApiOperation("获取导航条内容详细信息")
    @ApiImplicitParam(name = "id", value = "导航条内容ID", required = true, dataType = "Integer", paramType = "path", dataTypeClass=Integer.class)
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(cnNavigationBarContentService.selectCnNavigationBarContentById(id));
    }

    /**
     * 新增导航条内容
     */
    @ApiOperation("新增导航条内容")
    @PreAuthorize("@ss.hasPermi('system:navigationContent:add')")
    @Log(title = "导航条内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody CnNavigationBarContent cnNavigationBarContent) {
        return toAjax(cnNavigationBarContentService.insertCnNavigationBarContent(cnNavigationBarContent));
    }

    /**
     * 修改导航条内容
     */
    @ApiOperation("修改导航条内容")
    @PreAuthorize("@ss.hasPermi('system:navigationContent:edit')")
    @Log(title = "导航条内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody CnNavigationBarContent cnNavigationBarContent) {
        return toAjax(cnNavigationBarContentService.updateCnNavigationBarContent(cnNavigationBarContent));
    }

    /**
     * 删除导航条内容
     */
    @ApiOperation("删除导航条内容")
    @ApiImplicitParam(name = "ids", value = "导航条内容ID集合", required = true, dataType = "Integer", paramType = "path", dataTypeClass=Integer.class)
    @PreAuthorize("@ss.hasPermi('system:navigationContent:remove')")
    @Log(title = "导航条内容", businessType = BusinessType.DELETE)
	@PostMapping("/batchDelete")
    public AjaxResult batchDelete(@RequestBody List<String> ids) {
        return toAjax(cnNavigationBarContentService.deleteCnNavigationBarContentByIds(ids));
    }


}
